/*
 * @Author: HeAo
 * @Date: 2021-09-28 16:03:49
 * @LastEditTime: 2021-09-28 16:26:59
 * @LastEditors: HeAo
 * @Description:
 * @FilePath: \web2103-2105\web2105\3-1-ES6\day04\5-symbol.js
 * 别乱动！
 */
let s1 = Symbol('s1');
let s2 = Symbol('s2');
// console.log(s1, s2);
// console.log(s1 === s2);
// console.log(typeof s1);
// console.log(typeof null);
// console.log(typeof [1, 2, 3]);

let obj = {
  nama: 'zhangsan',
  age: 12,
  [s1]: 'lisi'
}
console.log(obj[s1]);

let s3 = Symbol('one')
let s4 = Symbol('one')
console.log(s3, s4);
console.log(s3 === s4);

// Symbol.for(key)第一次传入key，去全局注册表中检索，该key是否已经存在
// 如果存在，就返回该key对应的symbol值，否则创建
let s5 = Symbol.for('two')
let s6 = Symbol.for('two')
console.log(s5, s6);
console.log(s5 === s6);

let key = Symbol.keyFor(s5)
let key2 = Symbol.keyFor(s6)
console.log(key, key2);

let value = Symbol.for(key)
console.log(value === s5);

